package com.zhenhe.core.common.listener.session;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.zhenhe.core.common.global.signIn.LoginInfo;
import com.zhenhe.core.common.global.signIn.LoginInfoUtil;

/**
 * session过期监听
 * @author Administrator
 *
 */
public class SessionExpireListener implements HttpSessionListener{

	private final Logger log = LoggerFactory.getLogger(getClass());
	
	
	@Override
	public void sessionCreated(HttpSessionEvent se) {
		log.debug("session({})创建",se.getSession().getId());
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent se) {
		HttpSession session = se.getSession();
		log.debug("session({})销毁",se.getSession().getId());
		Object login = session.getAttribute(LoginInfoUtil.LOGININFO);
		if(login == null||!((LoginInfo)login).isSignIn()){
			return ;
		}
		log.info("用户{}退出",((LoginInfo)login).getLoginName());
	}

}
